Dough Git

clove/pkviewer

web/src/routes/s/[systemRef]/[memberRef]/+page.svelte

back to web/src/routes/s/[systemRef]/[memberRef]

<!-- web/src/routes/s/[systemRef]/[memberRef]/+page.svelte -->
<script lang="ts">
  import { buildPageTheme } from "$lib/theme.ts";
  import CustomStyle from "$lib/components/CustomStyle.svelte";
  import Icon from "$lib/components/Icon.svelte";
  import Meta from "$lib/components/Meta.svelte";
  import SiteDisclosure from "$lib/components/SiteDisclosure.svelte";
  import SocialLinks from "$lib/components/SocialLinks.svelte";
  import StaleNotice from "$lib/components/StaleNotice.svelte";
  import ThemeFonts from "$lib/components/ThemeFonts.svelte";
  import TokenStyle from "$lib/components/TokenStyle.svelte";

  let { data } = $props();

  const system = $derived(data.page.system);
  const member = $derived(data.member);
  const composition = $derived(data.page.composition);

  const showBanner = $derived(composition["banner.display"] !== "hidden");
  const showPronouns = $derived(composition["show.pronouns"] !== "false");
  const showBirthday = $derived(composition["show.birthday"] !== "false");

  // Tokens arrive already merged system-under-member, so inheritance is not re-applied
  const theme = $derived(buildPageTheme(data.page.tokens, null, composition));

  const name = $derived(member.displayName ?? member.name ?? member.hid);
  const systemName = $derived(system.name ?? system.hid);
</script>

<Meta
  title="{name} · pkviewer"
  description={member.description?.slice(0, 200) ?? null}
  path={data.page.canonicalPath}
  image={member.avatarUrl}
  type="profile"
/>

<main class="page stack" id="pkv-user">
  <ThemeFonts fonts={theme.fonts} />
  <TokenStyle
    vars={theme.vars}
    darkVars={theme.darkVars}
    colorScheme={theme.colorScheme}
    scope=":root"
  />

  <CustomStyle css={data.page.css} />

  {#if system.staleSinceMs !== null}
    <StaleNotice staleSinceMs={system.staleSinceMs} />
  {/if}

  <a class="breadcrumb" href="/s/{member.systemSlug ?? member.systemHid}">
    <Icon name="arrow-left" /> {systemName}
  </a>

  {#if showBanner && member.bannerUrl}
    <img class="banner" src={member.bannerUrl} alt="" />
  {/if}

  <header class="identity">
    {#if member.avatarUrl}
      <img class="avatar" src={member.avatarUrl} alt="" />
    {:else}
      <Icon name="person-circle" class="avatar" />
    {/if}
    <div class="stack-tight" style="min-width: 0">
      <h1 style="margin: 0; overflow-wrap: anywhere">{name}</h1>
      {#if member.name && member.displayName && member.name !== member.displayName}
        <p class="muted" style="margin: 0">{member.name}</p>
      {/if}
      <ul class="meta-list muted">
        <li><code>{member.hid}</code></li>
        {#if showPronouns && member.pronouns}
          <li>{member.pronouns}</li>
        {/if}
        {#if showBirthday && member.birthday}
          <li>{member.birthday}</li>
        {/if}
      </ul>
    </div>
  </header>

  {#if member.description}
    <section class="prose">
      <p style="white-space: pre-wrap">{member.description}</p>
    </section>
  {/if}

  <SocialLinks links={data.page.socials} />

  <SiteDisclosure />
</main>